package com.gx.spring.event.springevent;

import com.gx.spring.event.springevent.event.UserRegisterEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

/**
 * Created by GX on 2017/9/12.
 */
@Service
public class UserService {
    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;
    public void register(String name) {
        System.out.println("用户：" + name + " 已注册！");
        applicationEventPublisher.publishEvent(new UserRegisterEvent(name));
    }
}
